<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/11
 * Time: 14:21
 */

namespace app\common\model;
use think\Model;

class GasStation extends Model
{
    protected $name = "gas_station";

    public function getGasStationList ($where, $filed, $limit, $request, $keyword) {
        if ($keyword) {
        $data = $this
            ->field($filed)
            ->where($where)
//            ->whereOr('user_id', $keyword)
//            ->whereOr('name', $keyword)
//            ->whereOr('id', $keyword)
//            ->whereOr('phone', $keyword)
            ->whereOr('user_id|name|id|phone','like',"%$keyword%")
            ->order('create_time desc')
            ->paginate($limit, false, ['query' => $request->get()]);
        } else {
            $data = $this
                ->field($filed)
                ->where($where)
                ->order('create_time desc')
                ->paginate($limit, false, ['query' => $request->get()]);
        }

        return $data;
    }

    public function getGasStationInfo ($where, $field) {

       $detail = $this->where($where)->field($field)->find();


        return $detail;
    }

    public function updateGasStationInfo ($where, $data) {

        $res = $this->where($where)->update($data);

        return $res;

    }

    public function addGasStationInfo($data) {

        $res = $this->insert($data);

        return $res;
    }
}